package com.cskaoyan.controller.wx.order;

import com.cskaoyan.bean.MarketOrderGoods;
import com.cskaoyan.bean.bo.wx.order.OrderCommentBo;
import com.cskaoyan.bean.bo.wx.order.OrderIdBo;
import com.cskaoyan.bean.bo.wx.order.OrderListBo;
import com.cskaoyan.bean.bo.wx.order.OrderSubmitBo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.vo.wx.order.OrderDetailVo;
import com.cskaoyan.bean.vo.wx.order.OrderListSingleVo;
import com.cskaoyan.bean.vo.wx.order.OrderSubmitVo;
import com.cskaoyan.service.wx.order.WxOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Aaliyah
 * @date 2022/9/9 15:53
 * @description: 处理小程序订单模块的请求
 */
@RequestMapping("wx/order")
@RestController
public class WxOrderController {

    @Autowired
    WxOrderService wxOrderService;

    /**
     * @description: /wx/order/comment 请求的处理
     * @date: 2022/9/11 17:57
     * @param: [orderCommentBo] 封装了订单商品id和评论信息
     */
    @RequestMapping("comment")
    public BaseRespVo orderComment(@RequestBody OrderCommentBo orderCommentBo) {
        wxOrderService.orderComment(orderCommentBo);
        return BaseRespVo.ok(null);
    }

    /**
     * @description: /wx/order/comment 请求的处理
     * @date: 2022/9/9 15:58
     * @param: [orderListBo] 封装了分页信息以及需要展示的订单状态分类
     */
    @RequestMapping("list")
    public BaseRespVo<CommonData<OrderListSingleVo>> orderList(OrderListBo orderListBo) {
        return BaseRespVo.ok(wxOrderService.orderList(orderListBo));
    }

    /**
     * @description: wx/order/detail 请求的处理
     * @date: 2022/9/9 22:49
     * @param: [orderId] 订单id
     */
    @RequestMapping("detail")
    public BaseRespVo<OrderDetailVo> orderDetail(int orderId) {
        return BaseRespVo.ok(wxOrderService.orderDetail(orderId));
    }

    /**
     * @description: /wx/order/delete 请求的处理
     * @date: 2022/9/11 16:22
     * @param: [orderIdBo] 封装了订单id
     */
    @RequestMapping("delete")
    public BaseRespVo orderDelete(@RequestBody OrderIdBo orderIdBo){
        wxOrderService.orderDelete(orderIdBo);
        return BaseRespVo.ok(null);
    }

    /**
     * @description: /wx.order/confirm 请求的处理
     * @date: 2022/9/11 19:23
     * @param: [orderIdBo] 封装了订单id
     */
    @RequestMapping("confirm")
    public BaseRespVo orderConfirm(@RequestBody OrderIdBo orderIdBo){
        wxOrderService.orderConfirm(orderIdBo);
        return BaseRespVo.ok(null);
    }

    /**
     * @description: /wx/order/refund 请求的处理
     * @date: 2022/9/11 19:30
     * @param: [orderIdBo] 封装了订单id
     */
    @RequestMapping("refund")
    public BaseRespVo orderRefund(@RequestBody OrderIdBo orderIdBo){
        wxOrderService.orderRefund(orderIdBo);
        return BaseRespVo.ok(null);
    }

    /**
     * @description: /wx/order/goods 请求的处理
     * @date: 2022/9/11 20:05
     * @param: [orderId, goodsId] 订单id 商品id
     */
    @RequestMapping("goods")
    public BaseRespVo<MarketOrderGoods> orderGoods(Integer orderId, Integer goodsId) {
        return BaseRespVo.ok(wxOrderService.orderGoods(orderId,goodsId));
    }

    /**
     * @description: wx/order/submit 请求的处理
     * @date: 2022/9/12 9:14
     * @param: [orderSubmitBo] 封装了购物车、购物方式和地址相关的信息
     */
    @RequestMapping("submit")
    public BaseRespVo<OrderSubmitVo> orderSubmit(@RequestBody OrderSubmitBo orderSubmitBo) {
        return BaseRespVo.ok(wxOrderService.orderSubmit(orderSubmitBo));
    }

    /**
     * @description: wx/order/prepay 请求的处理
     * @date: 2022/9/12 9:20
     * @param: [orderIdBo] 订单id
     */
    @RequestMapping("prepay")
    public BaseRespVo orderPrePay(@RequestBody OrderIdBo orderIdBo) {
        wxOrderService.orderPrepay(orderIdBo);
        return BaseRespVo.ok(null);
    }

    /**
     * @description: /wx/order/cancel 请求的处理
     * @date: 2022/9/12 9:20
     * @param: [orderIdBo] 订单id
     */
    @RequestMapping("cancel")
    public BaseRespVo orderCancel(@RequestBody OrderIdBo orderIdBo) {
        wxOrderService.orderCancel(orderIdBo);
        return BaseRespVo.ok(null);
    }
}
